package boot.spring.po;

/**
 * @author 经纬
 * @since 2024/12/12 10:17
 */
public enum MessageTypeEnum {

    /**
     * 心跳ping
     */
    PING(-1),
    /**
     * 心跳pong
     */
    PONG(-2),

    /**
     * 一对一
     */
    ONE_ON_ONE(0),

    /**
     * 群发消息类型
     */
    GROUP(1);

    private final int code;

    MessageTypeEnum(int code) {
        this.code = code;
    }
    public int getCode() {
        return code;
    }
    public static MessageTypeEnum getByCode(int code) {
        for (MessageTypeEnum value : values()) {
            if (value.getCode() == code) {
                return value;
            }
        }
        throw new IllegalArgumentException("No matching constant for [" + code + "]");
    }
}
